public void createInvoice() { try { UpStream.perform(); this.inv = new InvoiceModel(); var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10; inv.id = ms.ToString(); inv.number = "IN" + ms.ToString(); inv.date = DateTime.Now.ToString("yyyy-MM-dd"); inv.department_id = DepartmentSettings.DepartmentId; inv.till_id = DepartmentSettings.TillId; inv.barcode = inv.number; dynamic invoice = inv.create(inv); if (invoice != null) { ActivityLogModel.track("invoice", "create", this.inv.id); invoiceNumber.Text = "" + invoice.number; } else { invoiceNumber.Text = "Unable to create Invoice"; } } catch (Exception ex) { invoiceNumber.Text = "Error: " + ex.Message.ToString(); } }
public string createLineItem(dynamic product) { InvoiceItemModel inv_item = new InvoiceItemModel(); var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10; inv_item.id = "INT" + ms.ToString(); inv_item.quantity = 1; inv_item.product_id = product.id; inv_item.unit = product.unit; inv_item.price = product.sale_price; inv_item.vat = Math.Round(product.sale_price * (product.vat / 100), 2); inv_item.total = product.sale_price; inv_item.name = product.name; inv_item.invoice_id = this.inv.id; inv_item.date = DateTime.Now.ToString("yyyy-MM-dd"); inv_item.create(inv_item); textBoxVat.Text = "" + this.inv.vat; ActivityLogModel.track("invoice_item", "create", inv_item.id); return(inv_item.id); }
public void updateInvoice() { this.inv.save(this.inv); ActivityLogModel.track("invoice", "update", this.inv.id); }
private Boolean processPayment(String amount) { double paid_amount = Math.Round(Convert.ToDouble(amount), 2); if (paid_amount > 0 && paid_amount <= netDue) { if (netDue > 0) { DialogResult dialogResult = MessageDialog.Show("Confirm Payment", "Are you want to make the payment "); if (dialogResult == DialogResult.Yes) { PaymentModel payment = new PaymentModel(); var ms = (DateTime.Now - DateTime.MinValue).TotalMilliseconds * 10; payment.id = ms.ToString(); if (this.paymentType == "") { payment.payment_method = "Cash"; } else { payment.payment_method = this.paymentType; } payment.invoice_id = invoice.id; payment.amount = paid_amount; payment.customer_id = invoice.customer_id; payment.department_id = invoice.department_id; payment.transaction_token = new Random().Next(1000) + invoice.id; payment.date = DateTime.Now.ToString("yyyy-MM-dd"); payment.create(payment); bool status = ActivityLogModel.track("payment", "create", payment.id); if (status) { paymentList.Rows.Add(payment.id, payment.payment_method, payment.invoice_id, payment.amount, payment.transaction_token, payment.date); netDue -= payment.amount; netDue = Math.Round(netDue, 2); invoice.net_due = netDue; } else { MessageDialog.ShowAlert("Unable to make payment! Please try again or contact admin", "Alert Message", "error"); } } } else { DialogResult result = MessageDialog.Show("Amount Paid!", "Invoice amount fully paid! Do you want to close payment form?"); if (result == DialogResult.Yes) { this.Close(); } } } else { MessageBox.Show("Amount should not be 0 or grater than due amount"); } if (netDue <= 0) { DialogResult result = MessageDialog.Show("Amount Paid!", "Invoice amount fully paid! Do you want to close payment form?"); if (result == DialogResult.Yes) { this.Close(); } this.invoice_form.paymentCompleted(); } amountTextBox.Focus(); amountTextBox.Text = "" + netDue; return(true); }