feat: bootstrap ordering templates
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/pr/woodpecker Pipeline is pending

This commit is contained in:
Aravinth Manivannan 2025-01-10 21:49:11 +05:30
parent 5c6e8dec86
commit 58edaf8cdb
Signed by: realaravinth
GPG key ID: F8F50389936984FF
41 changed files with 1105 additions and 53 deletions

View file

@ -1,4 +1,3 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,15 +12,11 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_BILL_PAGE: TemplateFile = TemplateFile::new(
"billing.add_bill",
"billing/add_bill.html",
);
pub const ADD_BILL_PAGE: TemplateFile =
TemplateFile::new("billing.add_bill", "billing/add_bill.html");
pub fn register_templates(t: &mut tera::Tera) {
ADD_BILL_PAGE
.register(t)
.expect(ADD_BILL_PAGE.name);
ADD_BILL_PAGE.register(t).expect(ADD_BILL_PAGE.name);
}
pub struct AddBillPage {
@ -65,5 +60,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -1,4 +1,3 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,10 +12,8 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"billing.add_line_item",
"billing/add_line_item.html",
);
pub const ADD_LINE_ITEM_PAGE: TemplateFile =
TemplateFile::new("billing.add_line_item", "billing/add_line_item.html");
pub fn register_templates(t: &mut tera::Tera) {
ADD_LINE_ITEM_PAGE
@ -65,5 +62,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -1,4 +1,3 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,15 +12,11 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const DELETE_BILL_PAGE: TemplateFile = TemplateFile::new(
"billing.delete_bill",
"billing/delete_bill.html",
);
pub const DELETE_BILL_PAGE: TemplateFile =
TemplateFile::new("billing.delete_bill", "billing/delete_bill.html");
pub fn register_templates(t: &mut tera::Tera) {
DELETE_BILL_PAGE
.register(t)
.expect(DELETE_BILL_PAGE.name);
DELETE_BILL_PAGE.register(t).expect(DELETE_BILL_PAGE.name);
}
pub struct DeleteBillPage {
@ -65,4 +60,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -12,10 +12,8 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const DELETE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"billing.delete_line_item",
"billing/delete_line_item.html",
);
pub const DELETE_LINE_ITEM_PAGE: TemplateFile =
TemplateFile::new("billing.delete_line_item", "billing/delete_line_item.html");
pub fn register_templates(t: &mut tera::Tera) {
DELETE_LINE_ITEM_PAGE
@ -64,4 +62,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -3,11 +3,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pub mod add_bill;
pub mod update_bill;
pub mod delete_bill;
pub mod add_line_item;
pub mod update_line_item;
pub mod delete_bill;
pub mod delete_line_item;
pub mod update_bill;
pub mod update_line_item;
pub fn register_templates(t: &mut tera::Tera) {
for template in [

View file

@ -1,4 +1,3 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,15 +12,11 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_BILL_PAGE: TemplateFile = TemplateFile::new(
"billing.update_bill",
"billing/update_bill.html",
);
pub const UPDATE_BILL_PAGE: TemplateFile =
TemplateFile::new("billing.update_bill", "billing/update_bill.html");
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_BILL_PAGE
.register(t)
.expect(UPDATE_BILL_PAGE.name);
UPDATE_BILL_PAGE.register(t).expect(UPDATE_BILL_PAGE.name);
}
pub struct UpdateBillPage {
@ -65,5 +60,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -1,4 +1,3 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,10 +12,8 @@ use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"billing.update_line_item",
"billing/update_line_item.html",
);
pub const UPDATE_LINE_ITEM_PAGE: TemplateFile =
TemplateFile::new("billing.update_line_item", "billing/update_line_item.html");
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_LINE_ITEM_PAGE
@ -65,5 +62,4 @@ mod tests {
.unwrap();
tw.write();
}
}
}

View file

@ -2,11 +2,12 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
pub mod billing;
pub mod identity;
pub mod inventory;
mod log;
pub mod ordering;
mod utils;
pub mod billing;
pub fn init() {
lazy_static::initialize(&utils::TEMPLATES);

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_CATEGORY_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_category",
"ordering/add_category.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_CATEGORY_PAGE
.register(t)
.expect(ADD_CATEGORY_PAGE.name);
}
pub struct AddCategoryPage {
ctx: RefCell<Context>,
}
impl AddCategoryPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_CATEGORY_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_category.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddCategoryPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_CUSTOMIZATION_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_customization",
"ordering/add_customization.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_CUSTOMIZATION_PAGE
.register(t)
.expect(ADD_CUSTOMIZATION_PAGE.name);
}
pub struct AddCustomizationPage {
ctx: RefCell<Context>,
}
impl AddCustomizationPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_CUSTOMIZATION_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_customization.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddCustomizationPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_KOT_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_kot",
"ordering/add_kot.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_KOT_PAGE
.register(t)
.expect(ADD_KOT_PAGE.name);
}
pub struct AddKotPage {
ctx: RefCell<Context>,
}
impl AddKotPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_KOT_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_kot.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddKotPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_line_item",
"ordering/add_line_item.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_LINE_ITEM_PAGE
.register(t)
.expect(ADD_LINE_ITEM_PAGE.name);
}
pub struct AddLineItemPage {
ctx: RefCell<Context>,
}
impl AddLineItemPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_LINE_ITEM_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_line_item.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddLineItemPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_ORDER_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_order",
"ordering/add_order.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_ORDER_PAGE
.register(t)
.expect(ADD_ORDER_PAGE.name);
}
pub struct AddOrderPage {
ctx: RefCell<Context>,
}
impl AddOrderPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_ORDER_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_order.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddOrderPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const ADD_PRODUCT_PAGE: TemplateFile = TemplateFile::new(
"ordering.add_product",
"ordering/add_product.html",
);
pub fn register_templates(t: &mut tera::Tera) {
ADD_PRODUCT_PAGE
.register(t)
.expect(ADD_PRODUCT_PAGE.name);
}
pub struct AddProductPage {
ctx: RefCell<Context>,
}
impl AddProductPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(ADD_PRODUCT_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-add_product.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(AddProductPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const DELETE_KOT_PAGE: TemplateFile = TemplateFile::new(
"ordering.delete_kot",
"ordering/delete_kot.html",
);
pub fn register_templates(t: &mut tera::Tera) {
DELETE_KOT_PAGE
.register(t)
.expect(DELETE_KOT_PAGE.name);
}
pub struct DeleteKotPage {
ctx: RefCell<Context>,
}
impl DeleteKotPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(DELETE_KOT_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-delete_kot.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(DeleteKotPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const DELETE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"ordering.delete_line_item",
"ordering/delete_line_item.html",
);
pub fn register_templates(t: &mut tera::Tera) {
DELETE_LINE_ITEM_PAGE
.register(t)
.expect(DELETE_LINE_ITEM_PAGE.name);
}
pub struct DeleteLineItemPage {
ctx: RefCell<Context>,
}
impl DeleteLineItemPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(DELETE_LINE_ITEM_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-delete_line_item.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(DeleteLineItemPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const DELETE_ORDER_PAGE: TemplateFile = TemplateFile::new(
"ordering.delete_order",
"ordering/delete_order.html",
);
pub fn register_templates(t: &mut tera::Tera) {
DELETE_ORDER_PAGE
.register(t)
.expect(DELETE_ORDER_PAGE.name);
}
pub struct DeleteOrderPage {
ctx: RefCell<Context>,
}
impl DeleteOrderPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(DELETE_ORDER_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-delete_order.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(DeleteOrderPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
pub mod add_category;
pub mod add_customization;
pub mod add_kot;
pub mod add_line_item;
pub mod add_order;
pub mod add_product;
pub mod delete_kot;
pub mod delete_line_item;
pub mod delete_order;
pub mod update_category;
pub mod update_customization;
pub mod update_kot;
pub mod update_line_item;
pub mod update_order;
pub mod update_product;
pub fn register_templates(t: &mut tera::Tera) {
for template in [
add_category::ADD_CATEGORY_PAGE,
add_customization::ADD_CUSTOMIZATION_PAGE,
add_kot::ADD_KOT_PAGE,
add_line_item::ADD_LINE_ITEM_PAGE,
add_order::ADD_ORDER_PAGE,
add_product::ADD_PRODUCT_PAGE,
delete_kot::DELETE_KOT_PAGE,
delete_order::DELETE_ORDER_PAGE,
delete_line_item::DELETE_LINE_ITEM_PAGE,
update_category::UPDATE_CATEGORY_PAGE,
update_customization::UPDATE_CUSTOMIZATION_PAGE,
update_kot::UPDATE_KOT_PAGE,
update_line_item::UPDATE_LINE_ITEM_PAGE,
update_order::UPDATE_ORDER_PAGE,
update_product::UPDATE_PRODUCT_PAGE,
]
.iter()
{
template.register(t).expect(template.name);
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_CATEGORY_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_category",
"ordering/update_category.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_CATEGORY_PAGE
.register(t)
.expect(UPDATE_CATEGORY_PAGE.name);
}
pub struct UpdateCategoryPage {
ctx: RefCell<Context>,
}
impl UpdateCategoryPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_CATEGORY_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_category.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateCategoryPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_CUSTOMIZATION_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_customization",
"ordering/update_customization.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_CUSTOMIZATION_PAGE
.register(t)
.expect(UPDATE_CUSTOMIZATION_PAGE.name);
}
pub struct UpdateCustomizationPage {
ctx: RefCell<Context>,
}
impl UpdateCustomizationPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_CUSTOMIZATION_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_customization.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateCustomizationPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_KOT_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_kot",
"ordering/update_kot.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_KOT_PAGE
.register(t)
.expect(UPDATE_KOT_PAGE.name);
}
pub struct UpdateKotPage {
ctx: RefCell<Context>,
}
impl UpdateKotPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_KOT_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_kot.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateKotPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_line_item",
"ordering/update_line_item.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_LINE_ITEM_PAGE
.register(t)
.expect(UPDATE_LINE_ITEM_PAGE.name);
}
pub struct UpdateLineItemPage {
ctx: RefCell<Context>,
}
impl UpdateLineItemPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_LINE_ITEM_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_line_item.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateLineItemPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_ORDER_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_order",
"ordering/update_order.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_ORDER_PAGE
.register(t)
.expect(UPDATE_ORDER_PAGE.name);
}
pub struct UpdateOrderPage {
ctx: RefCell<Context>,
}
impl UpdateOrderPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_ORDER_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_order.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateOrderPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::cell::RefCell;
use derive_builder::*;
use derive_more::*;
use serde::*;
use tera::Context;
use url::Url;
pub use super::*;
use crate::utils::*;
pub const UPDATE_PRODUCT_PAGE: TemplateFile = TemplateFile::new(
"ordering.update_product",
"ordering/update_product.html",
);
pub fn register_templates(t: &mut tera::Tera) {
UPDATE_PRODUCT_PAGE
.register(t)
.expect(UPDATE_PRODUCT_PAGE.name);
}
pub struct UpdateProductPage {
ctx: RefCell<Context>,
}
impl UpdateProductPage {
pub fn new() -> Self {
let mut ctx = context();
//ctx.insert(PAYLOAD_KEY, p);
let ctx = RefCell::new(ctx);
Self { ctx }
}
pub fn render(&self) -> String {
TEMPLATES
.render(UPDATE_PRODUCT_PAGE.name, &self.ctx.borrow())
.unwrap()
}
pub fn page() -> String {
let p = Self::new();
p.render()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn render_page_and_write() {
const FILE: &str = "./tmp/ordering-update_product.html";
let tw = TestWriterBuilder::default()
.file(FILE.into())
.contents(UpdateProductPage::page())
.build()
.unwrap();
tw.write();
}
}

View file

@ -49,6 +49,7 @@ lazy_static! {
crate::identity::register_templates(&mut tera);
crate::inventory::register_templates(&mut tera);
crate::billing::register_templates(&mut tera);
crate::ordering::register_templates(&mut tera);
tera
};
}

View file

@ -6,7 +6,6 @@
<title>Delete Bill | Vanikam</title>
</head>
<body>
Token Refreshed
<form action="/billing/bill/delete" method="post">
<button type="submit">Delete Bill</button>
</form>

View file

View file